package com.xgq.drink.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xgq.drink.entity.ProductResource;
import com.xgq.drink.mapper.ProductResourceMapper;
import com.xgq.drink.service.IProductResourceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xgq
 * @since 2025-03-25
 */
@Service
public class ProductResourceServiceImpl extends ServiceImpl<ProductResourceMapper, ProductResource> implements IProductResourceService {
    @Autowired
    private ProductResourceMapper productResourceMapper;
    @Override
    public List<ProductResource> getResourcesByProductId(Long productId) {
        // 查询与该商品ID关联的所有资源
        QueryWrapper<ProductResource> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("product_id", productId); // 假设数据库中商品资源表的字段名为 `product_id`
        return productResourceMapper.selectList(queryWrapper);
    }
}
